package com.xiaobaibai.bo.pay;

import com.xiaobaibai.common.PayCommon;
import com.xiaobaibai.common.WeixinCommon;
import lombok.Data;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Date;

@Data
public class WxPayCreateOrder {

    public WxPayCreateOrder(Payer payer,Amount amount,
                            String out_trade_no,String description) {
        this.description = description;
        this.out_trade_no = out_trade_no;
        this.amount = amount;
        this.payer = payer;
        this.appid= WeixinCommon.APPID;
        this.mchid=PayCommon.mchid;
        Date date=new Date();
        Date fairDate = DateUtils.addSeconds(date, 890);//14分50秒内要付款
        this.time_expire= DateFormatUtils.format(fairDate, "YYYY-MM-dd HH:mm:ss").replace(" ", "T")+"+08:00";
        this.notify_url=PayCommon.notifyUrl;
    }

    private String appid;

    private String mchid;//商户号

    private String description;//商品描述

    private String out_trade_no;//本系统内部订单号

    private String time_expire;//交易结束时间 格式:2015-05-20T13:29:35+08:00(+08:00固定)

    private String notify_url;//回调通知地址

    private Amount amount;//金额对象,单位为分

    private Payer payer;//支付者,传入openid即可

}
